<template>
  <el-form-item :rules="item.rules" :label="item.label" :prop="item.key">
    <!-- 这里要根据类型区分  输入框 下拉框 时间选择等 -->
    <el-input v-bind="{ ...$attrs, ...item.attrs }" v-if="item.type == 'input'" />


    <el-select v-bind="{ ...$attrs, ...item.attrs }" v-if="item.type == 'select'">
      <el-option v-for="(record) in item.optionList" :label="record[item.optionLabel]"
        :value="record[item.optionValue]" />

    </el-select>
    <el-date-picker
        v-bind="{ ...$attrs, ...item.attrs }"
        v-model="objAll[item.key]"
        v-if="item.type == 'date'"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        placeholder="选择日期"
        value-format="YYYY-MM-DD HH:mm:ss"
      />
  </el-form-item>
</template>


<script setup>

import { defineProps } from 'vue'; //获取父组件传的props和向父组件发送方法


// 获取父组件的传参
const props = defineProps({
  item: {
    type: Object,
    required: true,//是否必要传值
  },
  objAll:{
    type:Object,
    default:()=>{
      return {}
    }
  }
});
</script>
<style lang="less" scoped>
/deep/ .el-select{
  width: 180px !important;
  height: 28px !important;
}
/deep/.el-select__wrapper{
  height: 28px !important;

}
/deep/ .el-input{
  height: 28px !important;
}
</style>
  

